<?php

namespace app\controller;

use app\BaseController;
use app\service\BigService;
use app\Request;
use app\service\ImageService;
use think\facade\Config;
use think\Response;
use think\facade\Log;

class Index extends BaseController
{
    protected $bigServiec;
    protected $r; //Request 对象

    protected $imageService;

    public function __construct(BigService $bigServiec, Request $r, ImageService $imageService)
    {
        $this->bigServiec = $bigServiec;
        $this->r = $r;
        //$this->customMethod($r);
        $this->imageService = $imageService;
    }

    public function index()
        //https://www.kancloud.cn/a173512/thinkphp6/1327360
    {
        return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V' . \think\facade\App::version() . '<br/><span style="font-size:30px;">16载初心不改 - 你值得信赖的PHP框架</span></p><span style="font-size:25px;">[ V6.0 版本由 <a href="https://www.yisu.com/" target="yisu">亿速云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ee9b1aa918103c4fc"></think>';
    }


    //设置
    public function settime(Request $request)
    {
        $og = $request->post();
        $arr['controller'] = 'settime';
        $time = $og['time'];
        Config::set(['settime' => $time], 'time');
        $arr['time'] = '你设置了轮播秒数' . $time;
        $arr['config'] = Config::get('time');
        return json($arr);
    }

    public function fetchtime(Request $request)
    {
        $og = $request->post();
        $arr['controller'] = 'fetchtime';
        $arr['config'] = Config::get('time');
        return json($arr);
    }


    //texttime
    public function iotimeget(Request $request)
    {
        $file = './time.txt';
        $content = file_get_contents($file);
        $arr['time'] = $content;
        return json($arr);
    }

    public function codeget(Request $request)
    {
        $timestamp = time();
        $currentHour = date('G', $timestamp);
        $arr['cc'] = $currentHour; //17
        $arr['bigcode'] = md5($currentHour);

        return json($arr);
    }

    public function iotimeset(Request $request)
    {
        $og = $request->post();
        $time = $og['time'];
        $arr['controller'] = "iotimeset";
        $file = './time.txt';
        $handle = fopen($file, 'c');
        $content = $time;
        file_put_contents($file, $time);
        return json($arr);
    }


    public function bigshow(Request $request)
    {
        //入参是小程序post过来的
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $id = $og['id'];
        $themeid = $og['themeid'];
        $arr = $this->bigServiec->bigshow($uniacid, $id, $themeid);
        $arr['og'] = $og;
        return json($arr);
    }


    /**
     * 1.活动标题
     */
    public function activitietitle(Request $request)
    {
        //入参是小程序post过来的
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $id = $og['id'];
        $arr = $this->bigServiec->activitietitle($uniacid, $id);
        $arr['og'] = $og;
        return json($arr);
    }

    //ordersum
    //订单总量
    public function ordersum(Request $request)
    {
        //入参是小程序post过来的
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $id = $og['id'];
        $arr = $this->bigServiec->ordersum($uniacid, $id);
        $arr['og'] = $og;
        return json($arr);
    }

    //倒计时 countdown
    public function countdown(Request $request)
    {
        //入参是小程序post过来的
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $id = $og['id'];
        $arr = $this->bigServiec->countdown($uniacid, $id);
        $arr['og'] = $og;
        return json($arr);
    }

    //fullgourp
    public function fullgourp(Request $request)
    {
        //入参是小程序post过来的
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $id = $og['id'];
        $arr = $this->bigServiec->fullgourp($uniacid, $id);
        $arr['og'] = $og;
        $arr['action'] = 'fullgourp';
        return json($arr);
    }


    //6 准客，即未支付的 zhuncus
    //record
    //ut
    public function zhuncus(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $arr = $this->bigServiec->zhuncus($uniacid, $themeid);
        return json($arr);
    }

    //7 访客 ui
    public function fanssum(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $id = $og['id'];
        $arr = $this->bigServiec->fanssum($uniacid, $id);
        return json($arr);
    }

    //ui
    public function ui(Request $request)
    {
        //入参是小程序post过来的
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $id = $og['id'];
        $arr = $this->bigServiec->ui($uniacid, $id);
        $arr['og'] = $og;
        return json($arr);
    }

    //ut
    public function ut(Request $request)
    {
        //入参是小程序post过来的
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $arr = $this->bigServiec->ut($uniacid, $themeid);
        $arr['og'] = $og;
        $arr['action'] = 'ut';
        return json($arr);
    }

    //8-9 新客数量和老客数量
    //newcus 新客数量
    public function newoldcus(Request $request)
    {
        //入参是小程序post过来的
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $newold = '老';
        $arr = $this->bigServiec->newoldcus($uniacid, $themeid, $newold);
        $arr['og'] = $og;
        $arr['action'] = 'newoldcus';
        return json($arr);
    }

    //10已支付
    //payon 主要是ut
    public function payon(Request $request)
    {
        //同时三个入参
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $id = $og['id'];
        //先做已支付
        $arr = $this->bigServiec->payon($uniacid, $themeid);
        $arr['og'] = $og;
        $arr['action'] = 'payon';
        return json($arr);
    }

    //11 未支付
    //payoff 主要是ui
    public function payoff(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $id = $og['id'];
        //其实是访客
        $arr = $this->bigServiec->payoff($uniacid, $themeid, $id);
        $arr['og'] = $og;
        $arr['action'] = 'payoff';
        return json($arr);
    }

    //员工排行
    public function cusanking(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $id = $og['id'];
        $arr['og'] = $og;
        $arr['action'] = 'cusanking';
        $arr = $this->bigServiec->cusanking($uniacid, $themeid, $id);
        return json($arr);
    }

    //员工表
    public function worker(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $id = $og['id'];
        $arr['og'] = $og;
        $arr['action'] = 'worker';
        $arr = $this->bigServiec->worker($uniacid, $themeid, $id);
        return json($arr);
    }

    public function fans(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $id = $og['id'];
        $arr = $this->bigServiec->fans($uniacid, $themeid, $id);
        return json($arr);
    }

    public function workertop(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $id = $og['id'];
        $arr['og'] = $og;
        $arr['action'] = 'worker';
        $arr = $this->bigServiec->workertop($uniacid, $themeid, $id);
        return json($arr);
    }

    //团队排行
    public function grouptop(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $id = $og['id'];
        $arr['controller'] = 'grouptop';
        $arr = $this->bigServiec->grouptop($uniacid, $themeid, $id);
        return json($arr);
    }

    //红包排行
    public function redtop(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $arr['controller'] = 'redtop';
        $arr = $this->bigServiec->redtop($uniacid, $themeid);
        return json($arr);
    }

    //事件大屏
    public function eventslist(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $arr['controller'] = 'eventslist';
        $arr = $this->bigServiec->eventslist($uniacid, $themeid);
        return json($arr);
    }

    public function testfun(Request $request)
    {
        $og = $request->post();
        $arr['controller'] = $og;
        $array = [1, 2, 3, 4, 5, "a"];
        $slicedArray = array_slice($array, 0, 2);
        $arr['one'] = $slicedArray;
        // 1  2   3   4
        // 0  1   2   3
        $arr['two'] = array_slice($array, 2, count($array) - 2);
        //算法2
        $timestamp = time();
        $currentHour = date('G', $timestamp);
        //echo "当前时间是 $currentHour 点";
        $arr['cc'] = $currentHour; //17
        $arr['bigcode'] = md5($currentHour);
        return json($arr);
    }

    public function codeauth($bigcode)
    {
        $timestamp = time();
        $currentHour = date('G', $timestamp);
        $apicode = md5($currentHour);
        if ($bigcode == $apicode) {
            return true;
        }
        return false;
    }

    //findOrder
    public function findbyopen(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $openid = $og['openid'];
        $arr['controller'] = 'findOrder';
        $arr = $this->bigServiec->findOrder($uniacid, $themeid, $openid);
        return json($arr);
    }

    public function findbysn(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $sn = $og['sn'];
        $arr['controller'] = 'findbysn';
        $arr = $this->bigServiec->findbysn($uniacid, $themeid, $sn);
        return json($arr);
    }

    public function findbyrr(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $rr = $og['rr'];
        $arr['controller'] = 'findbyrr';
        $arr = $this->bigServiec->findbyrr($uniacid, $themeid, $rr);
        return json($arr);
    }
    //
    public function findbthemebyid(Request $request)
    {
        $og = $request->post();

        $themeid = $og['themeid'];
        $arr['controller'] = 'findbthemebyid';
        $arr = $this->bigServiec->findbthemebyid( $themeid);
        return json($arr);
    }

    public function testime(Request $request)
    {
        $og = $request->post();
        $str = $og['sql'];
        $arr['controller'] = 'testime';
        $arr = $this->bigServiec->testime($str);
        return json($arr);
    }

    public function yutest(Request $request)
    {
//        $arr['a']='a';
//        return json($arr);
        $og = $request->post();
        $text = $og['text'];
        $AppKey = "7f10bd2f882145a5b2ed1402b3b20eba";
        $AppSecret = "55643bdb52c74f2e9c269d34ba171b6f";

        $cty = new Cty();
        $url = "https://ai-global.ctapi.ctyun.cn" . "/v1/aiop/api/2z0yhhrzgv0g/tts/predict";

        $header = array();
        $header['appkey'] = 'c0b71c83e6ae902d68d9334e6410fb1c';

        if (isset($og['text'])) {
            $text = $og['text'];

        } else {
            $text = "今晚去吃火锅吗哈哈";
        }


        $body["Action"] = 'TTS';
        $body["TextData"] = $text;

        //$body = "{\"Action\": \"TTS\", \"TextData\": \"今晚去吃火锅吗\"}";

        $fileMap = array();
        $res = $cty->ctyun($AppSecret, $AppKey, $url, null, $header, $body, "POST", "application/json", null);

        return $res;
    }

    public function yuyinorderlist(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $id = $og['id'];
        $arr = $this->bigServiec->tentopOrder($uniacid, $themeid);
        $len = count($arr);
        //便利数组
        $filteredData = array();
        $arr['$len_1'] = count($filteredData);
        $sqldata = $arr['sqldata'];
        foreach ($sqldata as $item) {
            // if (!is_null($item['username'])) {
            if (isset($item['username']) && $item['username'] !== null) {
                //$filteredData[$key] = $item;
                array_push($filteredData, $item);
            }
        }
        $arr['sqldata'] = $sqldata;
        $arr['$len_2'] = count($filteredData);
        $arr['controller'] = 'yuyinlist';
        $arr['len'] = $len;

        return json($arr);
    }

    public function yuyinone(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $id = $og['id'];
        $recordid = $og['recordid'];
        $arr = $this->bigServiec->yuyinone($uniacid, $themeid, $recordid);
        $len = count($arr);
        //便利数组
        $filteredData = array();
        if (isset($arr['sqldata'])) {
            $sqldata = $arr['sqldata'];
            foreach ($sqldata as $item) {
                // if (!is_null($item['username'])) {
                //if (isset($item['username']) && $item['username'] !== null) {
                //$filteredData[$key] = $item;
                array_push($filteredData, $item);
                //}
            }
            //unset($arr['sqldata']);
            //todo
            $this->getbasestr($filteredData);
        } else {
            $arr['备注'] = "没有数据";
        }
        $arr['$len_2'] = count($filteredData);
        $arr['controller'] = 'yuyinlist';
        $arr['len'] = $len;
        $arr['new_data'] = $filteredData;
        return json($arr);

    }


    //比如10个订单
    public function yuyinlist(Request $request)
    {
        $og = $request->post();
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $id = $og['id'];
        $arr = $this->bigServiec->tentopOrder($uniacid, $themeid);
        $len = count($arr);
        //便利数组
        $filteredData = array();
        $arr['$len_1'] = count($filteredData);
        $sqldata = $arr['sqldata'];

        foreach ($sqldata as $item) {
            // if (!is_null($item['username'])) {
            //if (isset($item['username']) && $item['username'] !== null) {
            //$filteredData[$key] = $item;
            array_push($filteredData, $item);
            //}
        }
        //todo
        $this->getbasestr($filteredData);
        unset($arr['sqldata']);
        $arr['$len_2'] = count($filteredData);
        $arr['controller'] = 'yuyinlist';
        $arr['len'] = $len;
        $arr['new_data'] = $filteredData;

        return json($arr);
    }

    public function t3()
    {
        $AppKey = "7f10bd2f882145a5b2ed1402b3b20eba";
        $AppSecret = "55643bdb52c74f2e9c269d34ba171b6f";
        $cty = new Cty();
        $url = "https://ai-global.ctapi.ctyun.cn" . "/v1/aiop/api/2z0yhhrzgv0g/tts/predict";
        $header = array();
        $header['appkey'] = 'c0b71c83e6ae902d68d9334e6410fb1c';
        $body["Action"] = 'TTS';
        $body["TextData"] = '今晚吃火锅';
        //$body = "{\"Action\": \"TTS\", \"TextData\": \"今晚去吃火锅吗\"}";
        $fileMap = array();
        $res = $cty->ctyun($AppSecret, $AppKey, $url, null, $header, $body, "POST", "application/json", null);

        $result = $res["returnObj"];

        $filePath = 'output.mp3';
        $audio_wav_dd = $this->urlSafeBase64Decode($result["Audio"]);
        file_put_contents($filePath, $audio_wav_dd);


        $audio_wav_dd = $this->urlSafeBase64Decode($result["Audio"]);
        $mp3_base64_u1 = base64_encode($audio_wav_dd);
        //$arr['audio'] = $mp3_base64_u1;
        $arr['t3'] = $filePath;
        return json($arr);
    }

    public function test(Request $request)
    {
        //$word = $request->get("word");
        $word = $request->param('word');
        $AppKey = "7f10bd2f882145a5b2ed1402b3b20eba";
        $AppSecret = "55643bdb52c74f2e9c269d34ba171b6f";

        $cty = new Cty();
        $url = "https://ai-global.ctapi.ctyun.cn" . "/v1/aiop/api/2z0yhhrzgv0g/tts/predict";

        $header = array();
        $header['appkey'] = 'c0b71c83e6ae902d68d9334e6410fb1c';
        $body["Action"] = 'TTS';
        $body["TextData"] = $word;

        //$body = "{\"Action\": \"TTS\", \"TextData\": \"今晚去吃火锅吗\"}";

        $fileMap = array();
        $res = $cty->ctyun($AppSecret, $AppKey, $url, null, $header, $body, "POST", "application/json", null);

        $result = $res["returnObj"];
        //audio_wav_dd = base64.urlsafe_b64decode(result["Audio"])
        //print("audio base64 len:{}".format(len(audio_wav_dd)))
        $audio_wav_dd = $this->urlSafeBase64Decode($result["Audio"]);
        $mp3_base64_u1 = base64_encode($audio_wav_dd);
        $arr['audio'] = $mp3_base64_u1;
        return json($arr);

    }

    public function getbasestr(&$arr)
    {
        $AppKey = "7f10bd2f882145a5b2ed1402b3b20eba";
        $AppSecret = "55643bdb52c74f2e9c269d34ba171b6f";
        $cty = new Cty();
        $url = "https://ai-global.ctapi.ctyun.cn" . "/v1/aiop/api/2z0yhhrzgv0g/tts/predict";

        $header = array();
        $header['appkey'] = 'c0b71c83e6ae902d68d9334e6410fb1c';

        foreach ($arr as &$item) {
            $body = array();
            $body["Action"] = 'TTS';
            //$body["TextData"] = $item['username'] . "  有新的订单已支付请及时处理";
            //来源员工”，您的客户“关联订单”已下单，请及时处理
            if (isset($item['username']) && $item['username'] !== null) {
                $body["TextData"] = $item['username'] . ",您的客户 " . $item['guanlian_username'] . "已下单，请及时处理";
            } else {
                $body["TextData"] = "客户 " . $item['guanlian_username'] . "已下单，请及时处理";
            }
            $body["VoiceType"] = 1;
            $res = $cty->ctyun($AppSecret, $AppKey, $url, null, $header, $body, "POST", "application/json", null);
            $result = $res["returnObj"];
            //audio_wav_dd = base64.urlsafe_b64decode(result["Audio"])
            //print("audio base64 len:{}".format(len(audio_wav_dd)))
            $audio_wav_dd = $this->urlSafeBase64Decode($result["Audio"]);
            $str = base64_encode($audio_wav_dd);
            $item['audio'] = $str;

            unset($body);
        }
        unset($item);
    }


    function urlSafeBase64Decode($data)
    {
        // 将 URL 安全的 Base64 字符替换回标准 Base64 字符
        $data = strtr($data, '-_', '+/');

        // 添加缺失的填充字符，确保长度为4的倍数
        $mod4 = strlen($data) % 4;
        if ($mod4 > 0) {
            $data .= substr('====', $mod4);
        }

        // 使用标准 base64_decode 进行解码
        return base64_decode($data);
    }

    //增加滚动速率 5个档位 默认在第3档位
    public function playspeed(Request $request)
    {
        $speed = [1, 2, 3, 4, 5];
        $speedtxt = ["极慢", "慢", "正常", "快", "极快"];
        $cur = 3;
        $arr['speed'] = $speed;
        $arr['speedtxt'] = $speedtxt;
        $arr['cur'] = $cur;
        return json($arr);
    }

    public function onetts(Request $request)
    {
        $og = $request->post();
        if (isset($og['word'])) {
            $word = $og['word'];
        } else {
            $word = "欢迎光临";
        }
        $AppKey = "7f10bd2f882145a5b2ed1402b3b20eba";
        $AppSecret = "55643bdb52c74f2e9c269d34ba171b6f";
        $cty = new Cty();
        $url = "https://ai-global.ctapi.ctyun.cn" . "/v1/aiop/api/2z0yhhrzgv0g/tts/predict";
        $header = array();
        $header['appkey'] = 'c0b71c83e6ae902d68d9334e6410fb1c';
        $body = array();
        $body["Action"] = 'TTS';
        $body["TextData"] = $word;
        $body["VoiceType"] = 1;
        $res = $cty->ctyun($AppSecret, $AppKey, $url, null, $header, $body, "POST", "application/json", null);
        $result = $res["returnObj"];
        $audio_wav_dd = $this->urlSafeBase64Decode($result["Audio"]);
        $str = base64_encode($audio_wav_dd);
        $item['audio'] = $str;
        return json($item);
    }


    public function fetchpnames(Request $request)
    {
        $og = $request->post();
        $pids = $og['pids'];
        if (is_array($pids)) {
            $arr['flag'] = 'true';
        } else {
            $arr['flag'] = 'false';
        }

        $arr = $this->bigServiec->fetchpnames($pids);
        return json($arr);
    }

    public function phpfun()
    {
        //phpinfo();
        $arr['info'] = phpinfo();
        return $arr;
    }

    public function getheadlogo()
    {
        //ims_water_salegroup3_config
        //DB平台uniacid  和活动aid
    }



    public function haibao(Request $request)
    {
        //step_01 获取头像
        $uniacid = $request->get("uniacid");
        $themeid = $request->get("themeid");
        $openid = $request->get('openid');

        //findhaibao
        $arr_touxiang =  $this->bigServiec->findhaibao_touxiang($uniacid,$themeid,$openid);
        $len = count($arr_touxiang['sqldata']);
        if($len >0){
            $avatar_url = $arr_touxiang['sqldata'][0]['avatar'];
            //echo $avatar;
        }
        if(!isset($avatar_url)){
            echo "DB没有头像";
        }else{
            //echo $avatar_url;
        }

        $arr_head = $this->bigServiec->findhaibao_config($uniacid,$themeid);
        $len2 = count($arr_head['sqldata']);
        if($len2 >0){
            $value = $arr_head['sqldata'][0]['value'];
        }
        if(!isset($value)){
            echo "DB活动配置没有";
        }
        $arr_value = unserialize($value);

        $headdb =$arr_value['headlogo'];
        $head_url = "https://tuan.cmzg.vip/".$headdb;
        //echo "---";
        //echo $head_url;

        //抓一个接口图
//        $uniacid = 117;
//        $themeid= 7613;
        $api_url = "https://cm.cmzg.vip/app/index.php?i=$uniacid&c=entry&themeid=$themeid&openid=$openid&do=api_qrcode&m=water_salegroup3";
        $http_data = $this->curl_request($api_url, $method='get', $params=[], $header=[], $type='https');
        $jsonObject = json_decode($http_data);

        $arr_message = $jsonObject->message;
        if($arr_message->msg == "success"){  //Cannot use object of type stdClass as array
            //echo "http api 有二维码";
            $qrcode_url =$arr_message->qrcode;
        }else{
            echo "http api 没有二维码";
        }
        if(isset($qrcode_url)){
            //echo  $qrcode_url;

        }

        try {
            //$baseImageUrl = 'https://cm.cmzg.vip/addons/water_salegroup3/data/poster/24/5260/a0dce8b9e00d06b63bdedda266c80732.png';
            $baseImageUrl =$head_url;
            $overlayImageUrls = [
                //"https://tuan.cmzg.vip/images/water_salegroup3/20241107132339_5433906773_2964.jpeg", //头像
                $avatar_url,
                $qrcode_url
            ];
            // 定义每个叠加图的位置


            $positions = [
                'bottom-left' , //top-left改 bottom-left
//                'top-right',
                'bottom-right'
            ];
            // 调用服务方法
            $this->imageService->mergeMultipleImagesToBrowser($baseImageUrl, $overlayImageUrls, $positions);
            // 返回图像数据
            header("Content-Type: image/png; charset=utf-8");
            echo $baseImageUrl;
            exit;
            // 获取缓冲区内容并清除缓冲区
            //$imageData = ob_get_clean();

        } catch (\Exception $e) {
            return json(['status' => 'error', 'message' => $e->getMessage()]);
        }
    }

    function curl_request($url, $method='get', $params=[], $header=[], $type='http'){
        /**
         * 初始化curl，返回资源
         */
        $curl = curl_init($url);
        /**
         * 默认是get请求，如果是post/put请求，设置请求方式和请求参数
         */
        if (strtoupper($method) == 'POST'){
            curl_setopt($curl,CURLOPT_POST,true);
            curl_setopt($curl,CURLOPT_POSTFIELDS,$params);
        }
        if (strtoupper($method) == 'PUT'){
            curl_setopt($curl,CURLOPT_PUT,true);
        }
        /**
         * 设置header头部传参
         */
        if(!empty($header)){
            curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
        }
        /**
         * 如果是HTTPS协议，禁止从服务器验证本地证书
         */
        if (strtoupper($type) == 'HTTPS'){
            curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false);
            curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
        }
        /**
         * 超时设置，单位毫秒
         */
        curl_setopt( $curl, CURLOPT_TIMEOUT_MS,10000);
        /**
         * 发送请求，返回结果
         */
        curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
        /**
         * 不验证ssl
         */
        curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
        /**
         * 选择地址
         * curl_setopt($curl,CURLOPT_URL,$url);
         */
        $res = curl_exec($curl);

        if ($res === false) {
            $error = curl_error($curl);
            curl_close($curl);
            // 抛出一个异常或返回错误信息
            throw new Exception("CURL Error: " . $error);
        }

        /**
         * 关闭请求
         */
        curl_close($curl);
        return $res;

    }

    public function findconfig(Request $request)
    {
        //step_01 获取头像
        $uniacid = $request->get("uniacid");
        $themeid = $request->get("themeid");

        $arr_head = $this->bigServiec->findhaibao_config($uniacid,$themeid);
        dump($arr_head);
    }

    //findhaibao_config_t
    public function findhaibao_config_t(Request $request)
    {
        //step_01 获取头像
        $themeid = $request->get("themeid");

        $arr_head = $this->bigServiec->findhaibao_config_t($themeid);
        dump($arr_head);
    }

    //根据平台id; uniacid 和 themeid 查询所有员工列表
    public function the_worklist(Request $request){
        $uniacid = $request->get("uniacid");
        $themeid = $request->get("themeid");

        $arr = $this->bigServiec->the_worklist($uniacid,$themeid);
        return json($arr);
    }

    //post
    public function edit_work_by_openid(Request $request){
        $og = $request->post();
        Log::write('edit_work_by_openid 入参'.json_encode($og),'INFO');
        //Log::record('访问了someAction方法', 'info');
        $uniacid = $og['uniacid'];
        $themeid = $og['themeid'];
        $openid =  $og['openid'];
        $identity = $og['identity'];
        $status = $og['status'];

        $arr = $this->bigServiec->edit_work_by_openid($uniacid,$themeid,$openid,$identity,$status);
        return json($arr);
    }

}
